package com.xbao.service.impl;

import com.xbao.core.util.MyBeanUtil;
import com.xbao.dao.StuMapper;
import com.xbao.dao.StuRecordCheckExtraMapper;
import com.xbao.dao.StuRecordCheckMapper;
import com.xbao.model.*;
import com.xbao.model.req.CheckQuery;
import com.xbao.model.vo.StuVo;
import com.xbao.service.StuRecordCheckService;
import com.xbao.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by qingshengzheng on 2019/1/31.
 */
public class StuRecordCheckServiceImpl implements StuRecordCheckService {
    @Autowired
    private StuRecordCheckMapper stuRecordRelMapper;
    @Autowired
    private StuRecordCheckExtraMapper stuRecordCheckExtraMapper;

    @Resource
    private StuService stuService;

    @Autowired
    private StuMapper stuMapper;

    @Override
    public void addStuRecordRel(StuRecordCheckReq rel) {
        stuRecordRelMapper.insert(rel);

    }

    @Override
    public void addStuRecordRels(List<StuRecordCheckReq> rel) {

    }

    @Override
    public void updateStuRecordRel(StuRecordCheckReq rel) {
        StuRecordCheckExample example = new StuRecordCheckExample();
        StuRecordCheckExample.Criteria criteria = example.createCriteria();


    }

    @Override
    public void deleteStuRecord(Long id) {
        stuRecordRelMapper.deleteByPrimaryKey(id);

    }

    @Override
    public List<StuRecordCheckVo> relOfRecord(CheckQuery checkQuery) {
        StuRecordCheckExample example = new StuRecordCheckExample();
        StuRecordCheckExample.Criteria criteria = example.createCriteria();
        criteria.andCidEqualTo(checkQuery.getCid());
        criteria.andSubidEqualTo(checkQuery.getSubid());
        List<StuRecordCheck> rels = stuRecordRelMapper.selectByExample(example);
        List<StuRecordCheckVo> vos = MyBeanUtil.copyList(rels, StuRecordCheckVo.class);
        return vos;
    }

    @Override
    public List<StuRecordCheckVo> relOfStu(CheckQuery checkQuery) {
        StuRecordCheckExample example = new StuRecordCheckExample();
        StuRecordCheckExample.Criteria criteria = example.createCriteria();
        criteria.andSidEqualTo(checkQuery.getSid());
        criteria.andCidEqualTo(checkQuery.getCid());
        List<StuRecordCheck> rels = stuRecordRelMapper.selectByExample(example);
        List<StuRecordCheckVo> vos = MyBeanUtil.copyList(rels, StuRecordCheckVo.class);
        return vos;
    }


    public List<StuRecordCheckVo> getStusOfClsList(CheckQuery checkQuery) {
        List<StuRecordCheck> checks=stuRecordCheckExtraMapper.getStusOfClsList(checkQuery);
        List<StuRecordCheckVo> vos=MyBeanUtil.copyList(checks,StuRecordCheckVo.class);
        return vos;
    }


}
